package com.xzkj.ad

import android.app.Activity
import com.ifmvo.togetherad.core.helper.AdHelperReward
import com.ifmvo.togetherad.core.listener.RewardListener

object RewardAd {
    val tag = "RewardAd"
    var adHelperReward: AdHelperReward ?= null

     fun load(activity: Activity,
              listener: RewardListener? = null) {
         adHelperReward = AdHelperReward(
             activity = activity,
             alias = TogetherAdAlias.AD_REWARD,
             listener = listener
         )
         adHelperReward?.load()
     }

    fun show(){
        adHelperReward?.show()
    }

    /**
     * 加载成功后立即显示
     */
    fun loadAndShow(activity: Activity,
                    listener: RewardListener? = null){
        load(activity, object :RewardListener{
            override fun onAdClicked(providerType: String) {
                listener?.onAdClicked(providerType)
            }

            override fun onAdExpose(providerType: String) {
                listener?.onAdExpose(providerType)
            }

            override fun onAdFailed(providerType: String, failedMsg: String?) {
                listener?.onAdFailed(providerType, failedMsg)
            }

            override fun onAdFailedAll(failedMsg: String?) {
                listener?.onAdFailedAll(failedMsg)
            }

            override fun onAdShow(providerType: String) {
                listener?.onAdShow(providerType)
            }

            override fun onAdStartRequest(providerType: String) {
                listener?.onAdStartRequest(providerType)
            }

            override fun onAdLoaded(providerType: String) {
                show()
            }

            override fun onAdVideoCached(providerType: String) {
                show()
            }

            override fun onAdClose(providerType: String) {
                listener?.onAdClose(providerType)
            }

            override fun onAdRewardVerify(providerType: String) {
                listener?.onAdRewardVerify(providerType)
            }

            override fun onAdVideoComplete(providerType: String) {
                listener?.onAdVideoComplete(providerType)
            }
        })
    }
}